package Solution101_200.problem101.SymmetricTree;

import common.TreeNode;

/**
 * @program Leetcode
 * @description:
 * @author: lishangsheng
 * @create: 2019/07/10 11:40
 */
public class Solution {

    public boolean isSymmetric(TreeNode root) {
        /*如果为空则是对称树*/
        if(root==null){
            return true;
        }
        /*左右子树做对比*/
        return isSymmetric(root.left,root.right);
    }
    private boolean isSymmetric(TreeNode left,TreeNode right) {
        /*如果为空则是对称树*/
        if(left==null&&right==null){
            return true;
        }
        if(left==null||right==null){
            return false;
        }
        if(left.val!=right.val){
            return false;
        }
        /*继续往下判断*/
        return isSymmetric(left.left,right.right)&&isSymmetric(left.right,right.left);
    }

}
